<%@page import="merlin.managers.ReportTitlesManager"%>
<%@page import="merlin.beans.ReportTitlesBean"%>
<%@page import="merlin.utils.MerlinUtilities"%>
<%@ page language="java" contentType="text/html; charset=ISO-8859-1"
    pageEncoding="ISO-8859-1"%>

<%
	String token  = request.getParameter("token");

	if(MerlinUtilities.isEmpty(token)){
		out.println("invalid parameters.");
		return;
	}
	
	int recordId = 0;
	try{
		recordId = Integer.parseInt(token, 16);
	}catch(Exception e){
		e.printStackTrace();
		out.println("Incorrect download token.");
		return;
	}
	
	// Get the report datails based on the record ID.
	ReportTitlesBean bean = ReportTitlesManager.selectReportTitleByFreeReportDownloadRecordId(recordId);
	if(bean == null){
		out.println("No reports found.");
		return;
	}
%>

<html>
	<head>
		<meta charset="utf-8"/>
		<meta content="IE=edge, chrome=1" http-equiv="X-UA-Compatible"/>
		<meta name="viewport" content="width=device-width, initial-scale=1.0">
	
		<!-- Bootstrap CSS -->
		<link href="bootstrap/css/bootstrap.min.css" rel="stylesheet">
		<link href="includes/css/bootstrap-glyphicons.css" rel="stylesheet">
	
		<!-- Custom CSS -->
		<link rel="stylesheet" href="includes/css/styles.css">
		
		<!-- Include Modernizr in the head, before any other Javascript -->
		<script src="includes/js/modernizr-2.6.2.min.js"></script>
	
		<!-- Bootstrap JS -->
		<script src="bootstrap/js/bootstrap.min.js"></script>

		<!-- begin DWR imports -->
		<script type='text/javascript' src='dwr/interface/WebsiteEnquiriesManager.js'></script>
		<script type='text/javascript' src='dwr/engine.js'></script>
		<script type='text/javascript' src='dwr/util.js'></script>
		<!-- ends DWR imports -->

		<!-- begin jQuery import -->
		<script type='text/javascript' src='mr_scripts/jquery.js'></script>
		<!-- ends jQuery import -->
		<title>Free <%=MerlinUtilities.capitalizeFully(bean.getReportTitle())%> Reports Download Page</title>
	</head>
	<body>
		<% 
			String reportNameUpperCase = bean.getReportTitle().toUpperCase();
			String reportNameLowerCase = bean.getReportTitle().toLowerCase();
			String reportNameTitleCase = MerlinUtilities.capitalizeFully(bean.getReportTitle());
			String reportCode = bean.getReportCode();
		%>
		<div class="container">
			<div class="navbar navbar-fixed-top">
				<div class="navbar-custom">
					<div class="container">
						<a class="navbar-brand" href="#"><img class="img-responsive" src="images/Merlin.png" alt="Merlin Scott  Logo"></img></a>
					</div><!--end container-->
				</div><!--end navbar-inner-->
			</div><!--end navbar-->
			<div class="container">
				<div class="row">
					<div class="col-12">
						<div class="header centered">
							<h2>Merlin Scott Associates</h2>
						</div><!--end header centerer-->
						<div class="centered">
							<h2><a href="merlin?mode=msalFreeReportDownload&downloadId=<%=token%>">Use this link</a> to download your Free <%=reportNameTitleCase%> sector report</h2>
						</div><!--end centered-->
						<div class="message">
							<p>The FREE report above features 7 of the best firms to own in the <%=reportNameTitleCase%> sector.</p>  
							<p>The FREE report is an example of the analysis reports you can prepare for yourself using the latest Full Industry Report on the <%=reportNameTitleCase%> sector by Merlin Scott Associates Ltd.</p>
							<p><a href=http://www.merlinscottassociates.co.uk/MSAL/RLN/<%=reportCode%>.html>The FULL <%=reportNameUpperCase%> report features the latest information and analysis of all the <%=bean.getNoOfCompaniesInDatabase()%> firms listed on this link.</a>  The whole report is updated each week and the highlighted firms on the listing are those most recently changed.</p>
						</div><!--end message-->
					</div><!--end col-12-->
				</div><!--end row-->
			</div><!--end container-->
		</div><!--end container-->
	</body>
</html>